package com.foreverwin.jzymes.framework.webservice;

import com.foreverwin.jzymes.production.picking.service.IPickFeedService;
import com.foreverwin.jzymes.production.picking.service.impl.PickFeedServiceImpl;
import org.apache.cxf.Bus;
import org.apache.cxf.bus.spring.SpringBus;
import org.apache.cxf.jaxws.EndpointImpl;
import org.apache.cxf.transport.servlet.CXFServlet;
import org.springframework.boot.context.embedded.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.xml.ws.Endpoint;

@Configuration
public class WebServiceConfig {

    @Bean
    public ServletRegistrationBean webServiceServlet(){
        return new ServletRegistrationBean(new CXFServlet(),"/service/*");//发布服务名称
    }

    @Bean(name = Bus.DEFAULT_BUS_ID)
    public SpringBus springBus()
    {
        return  new SpringBus();
    }

    @Bean
    public IPickFeedService pickFeedService(){
        return new PickFeedServiceImpl();
    }

    @Bean
    public Endpoint endpoint() {
        EndpointImpl endpoint = new EndpointImpl( springBus(), pickFeedService() );
        endpoint.publish("/pickItem"); //显示要发布的名称
        return endpoint;
    }
}
